package rs.ac.bg.etf.estudent.fragment;

import java.util.ArrayList;
import java.util.HashMap;

import rs.ac.bg.etf.estudent.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class RegistrationFragment extends Fragment {
	
	private SimpleAdapter mRegTable;
	private ListView regList, tRegList;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view =  inflater.inflate(R.layout.fragment_registration, container, false);
		regList = (ListView)view.findViewById(R.id.reg_table);
		tRegList = (ListView)view.findViewById(R.id.taken_reg_table);
		View regHeaderView = inflater.inflate(R.layout.reg_list_header,null,false);
		View posRegHeaderView = inflater.inflate(R.layout.taken_reg_list_header, null, false);
		regList.addHeaderView(regHeaderView);
		tRegList.addHeaderView(posRegHeaderView);
		return view;
	}
	
	@Override
	public void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		 
		ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("akronim", "IR4PP1");
		map.put("naziv", "Programski prevodioci 1");
		map.put("ngr", "1");
		map.put("espb", "6");
		map.put("tip", "obavezan predmet");
		map.put("broj", "1");
		map.put("prof", "Nikolic Bosko");
		
		mylist.add(map);
		map = new HashMap<String, String>();
		map.put("akronim", "IR3SP");
		map.put("naziv", "Sistemsko programiranje");
		map.put("ngr", "1");
		map.put("espb", "6");
		map.put("tip", "obavezan predmet");
		map.put("broj", "2");
		map.put("prof", "Sasa Stojanovic");
		mylist.add(map);
		// ...
		mRegTable = new SimpleAdapter(getActivity(), mylist, R.layout.reg_list_item,
		            new String[] {"akronim", "naziv","ngr","espb","tip","broj","prof"}, new int[] {R.id.reg_acronym, R.id.reg_title,R.id.reg_ngr,
									R.id.reg_espb, R.id.reg_type,R.id.reg_count, R.id.reg_exam_profesor});
		regList.setAdapter(mRegTable);
	}

}
